package db;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import setupdb.Main;


public class TuneDB {

	private BufferedWriter writer;

	public TuneDB(String filename) {
		try {
			writer = new BufferedWriter(new FileWriter(new File(
					Main.DB_OUT_FOLDER, filename)));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void writeln(String text) {
		try {
			writer.write(text + "\r\n");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void closedDB() {
		try {
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void writeRecord(DBRecord record) {
		writeln(record.getTitle());
		writeln("\t" + record.getArtist());
		writeln("\t" + record.getRelativeFolder());
		writeln("\t" + record.getRating());
	}
}
